package chess;

import chess.pieces.*;
import abstractgame.GamePiece;
import abstractgame.GameState;	//should not be needed?
import abstractgame.GameType;

public class ChessType extends GameType {

	// GameState should be ChessState?
	public void createDefaultPieces(GameState state) {
		// Create position array
		int[] pos = new int[1];
		// Declare a temporary piece
		GamePiece piece;
		// Create black pawns
		pos[1] = 1;
		for (int i = 0; (i < 8); i++) {
			pos[0] = i;
			piece = new Pawn(state, pos);
			state.addPiece(piece, GameState.SIDE_BLACK);
		}
		// Create white pawns
		pos[1] = 6;
		for (int i = 0; (i < 8); i++) {
			pos[0] = i;
			piece = new Pawn(state, pos);
			state.addPiece(piece, GameState.SIDE_WHITE);
		}
		// Create black rooks
		pos[0] = 0;
		pos[1] = 0;
		piece = new Rook(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		pos[0] = 7;
		piece = new Rook(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		// Create white rooks
		pos[0] = 0;
		pos[1] = 7;
		piece = new Rook(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		pos[1] = 7;
		piece = new Rook(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		// Create black knights
		pos[0] = 1;
		pos[1] = 0;
		piece = new Knight(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		pos[1] = 6;
		piece = new Knight(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		// Create white knights
		pos[0] = 1;
		pos[1] = 7;
		piece = new Knight(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		pos[1] = 6;
		piece = new Knight(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		// Create black bishops
		pos[0] = 2;
		pos[1] = 0;
		piece = new Bishop(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		pos[1] = 5;
		piece = new Bishop(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		// Create white bishops
		pos[0] = 2;
		pos[1] = 7;
		piece = new Bishop(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		pos[1] = 5;
		piece = new Bishop(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		// Create black queen
		pos[0] = 3;
		pos[1] = 0;
		piece = new Queen(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		// Create white queen
		pos[0] = 3;
		pos[1] = 7;
		piece = new Queen(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
		// Create black king
		pos[0] = 4;
		pos[1] = 0;
		piece = new King(state, pos);
		state.addPiece(piece, GameState.SIDE_BLACK);
		// Create white king
		pos[0] = 4;
		pos[1] = 7;
		piece = new King(state, pos);
		state.addPiece(piece, GameState.SIDE_WHITE);
	}

}
